package me.ymfs.springboot.guice.exception;

import static me.ymfs.springboot.guice.exception.ErrorType.*;

public enum ErrorCodes implements ErrorCodeSupplier {

    USER_ERR("10000", USER_ERROR),
    PARAM_ERR("10001", "参数错误", USER_ERROR),

    INTERNAL_ERR("20000", INTERNAL_ERROR),

    INSUFFICIENT_RESOURCES_ERR("30000", INSUFFICIENT_RESOURCES),

    EXTERNAL_ERR("40000", EXTERNAL)
    ;


    private final ErrorCode errorCode;

    ErrorCodes(String code, ErrorType errorType) {
        this.errorCode = new ErrorCode(code, name(), errorType);
    }

    ErrorCodes(String code, String msg, ErrorType errorType) {
        this.errorCode = new ErrorCode(code, msg, errorType);
    }

    @Override
    public ErrorCode toErrorCode() {
        return this.errorCode;
    }

}
